﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 
	<span class="c-gray en">&gt;</span> 管理员管理 
	<span class="c-gray en">&gt;</span> 管理员列表 
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<div class="page-container">
	<form action="{:url('admin_list')}" method="get">
		<div class="text-c"> 日期范围：
			<input type="text" name="stime" value="{$stime}" onfocus="WdatePicker()" id="datemin" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" name="etime" value="{$etime}" onfocus="WdatePicker()" id="datemax" class="input-text Wdate" style="width:120px;">
			<!--<select name="type" class="input-text Wdate" style="width:100px">
				<option value="">会员类型</option>
				<option value="0" {:$type==='0'?'selected':''}>超级管理员</option>
				<option value="1" {:$type==1?'selected':''}>培训机构</option>
				<option value="2" {:$type==2?'selected':''}>考官</option>
			</select>-->
			<input type="text" name="keys" value="{$keys}" class="input-text" style="width:150px;" placeholder="请输入培训机构名字">
			<button type="submit" class="btn btn-success"><i class="Hui-iconfont">&#xe665;</i> 点击搜索</button>
			<button type="button" class="getList btn btn-success" style="background-color: #fb0303;border-color: #fb0303;"><i class="Hui-iconfont">&#xe640;</i> 下载机构列表</button>
		</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" class="btn btn-danger radius adminDelAll"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
			<a href="{:url('admin_add')}" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>
		</span>
		<span class="r">共有数据：<strong>{:$list->total()}</strong> 条</span> </div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">管理员列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" value=""></th>
				<th>编号</th>
				<th>登录名</th>
				<th>会员类型</th>
				<th>机构（考官）名称</th>
				<th>机构地址</th>
				<th>考官</th>
				<th>营业执照</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			{volist name="list" id="l"}
			<tr class="text-c">
				<td><input type="checkbox" value="{$l.id}" name="ids"></td>
				<td>{$l.id}</td>
				<td>{$l.name}</td>
				<td>{:$l.type==0?'超级管理员':''}{:$l.type==1?'培训机构':''}{:$l.type==2?'考官':''}</td>
				<td>{:$l.type==1?$l.sname:''}{:$l.type==2?$l.real_name:''}</td>
				<td>{if condition="$l.address neq ''"}{$l.address}{/if}</td>
				<td><a class="add-kaoguan" data-id="{$l.sid}" data-aid="{$l.kg_id}" data-name="{$l.sname}">{if condition="$l.type eq 1"}{if condition="$l.kg_id neq ''"}{$l.kg_name}{else /}添加考官{/if}{/if}</a></td>
				<td>{if condition="$l.files neq ''"}<img src="{$l.files}" style="max-width: 80px;max-height: 100px;">{/if}</td>
				<!-- <td class="td-status">{if condition="$l.hidden eq 0"}<span class="label label-success radius">已启用</span>{else /}<span class="label radius">已停用</span>{/if}</td> -->
				<td class="td-manage">
					<a title="编辑" href="{:url('admin_add')}?id={$l.id}" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" class="ml-5 adminDel" style="text-decoration:none" data-id="{$l.id}"><i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>
			</tr>
			{/volist}
		</tbody>
	</table>
	<div class="page">{:$list->render()}</div>

</div>
<!--_footer 作为公共模版分离出去-->
{include file="public/js"}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
	$(".states").click(function(){
		var $this=$(this);
		var id=$this.attr("data-id");
			title=$this.attr('title');
		var index=layer.confirm('确认'+title+'该账号吗？',function(){
			layer.close(index)
			$.post("{:url('admin_state')}",{id:id},function(res){
				if (res.state==200) {
					layer.msg(res.msg,{icon:1},function(){
						window.location.reload();
					});
				}else{
					layer.msg(res.msg,{icon:2});
				}
			})
		})
	})

	function adminDel(id){
		var index=layer.confirm('确定删除数据？',{btn:['确定','取消']},function(){
			layer.close(index);
			$.post("{:url('index/admin_del')}",{id:id},function(res){
				//console.log(res)
				if (res.state==200) {
					layer.msg(res.msg,{icon:1},function(){
						window.location.reload();
					})
				}else{
					layer.msg(res.msg,{icon:2});
				}
			})
		})
	}

	$(".adminDelAll").click(function(){
		var ids='';
		$("input[name=ids]:checked").each(function(){
			if (ids!='') {
				ids+=','+$(this).val();
			}else{
				ids=$(this).val();
			}
		})
		if (ids!='') {
			adminDel(ids)
		}else{
			layer.msg('请选择要删除的数据',{icon:2})
		}		
	})

	$(".adminDel").click(function(){
		var id=$(this).attr('data-id');
		adminDel(id);
	})

	$(".add-kaoguan").click(function(){
		var sid=$(this).attr("data-id");
			kid=$(this).attr("data-aid");
			sname=$(this).attr("data-name");
		if (sid=='' || sname=='') {
			layer.msg('机构信息未完善，请先完善机构信息!',{icon:7,time:1500});return false;
		}
		$.post("{:url('get_kg')}",'',function(res){
			if (res.code==200) {
				//console.log(res.info)
				var html='';
					html+='<form id="myform">';
					html+='<div style="color:#000;position:absolute;top:50%;height:30%;width: 50%;margin: -10% 0 0 25%;"">';
					html+='选择考官';
					html+='<select name="kaoguan">';
					html+='<option value="">请选择考官</option>';
					for(var i in res.info){
						//console.log(res.info[i]);
						if(kid==res.info[i]['id']){
							html+='<option value="'+res.info[i]['id']+'" selected>'+res.info[i]['real_name']+'</option>';
						}else{
							html+='<option value="'+res.info[i]['id']+'">'+res.info[i]['real_name']+'</option>';
						}
					}
					html+='</select>';
					html+='</div>';
					html+='</form>';
				var index=layer.open({
					type: 1,
					title:'添加考官',
					skin: 'layui-layer-rim', //加上边框
					area: ['420px', '240px'], //宽高
					content: html,
					btn:['确定','取消'],
					yes:function(){
						var aid=$("select[name=kaoguan]").find("option:selected").val();
						if (aid!='') {
							$.post("{:url('school_addAid')}",{sid:sid,aid:aid},function(ret){
								//console.log(ret);
								layer.close(index)
								if(ret.code==200){
									layer.msg(ret.msg,{icon:1,time:1000},function(){
										location.replace(location.href);
									});
								}else{
									layer.msg(ret.msg,{icon:7,time:1000});
								}
							})
						}else{
							layer.msg('请选择考官！',{icon:7,time:1500});
						}
					}
				})
			}else{
				layer.msg('无符合条件考官',{icon:1,time:1000});
			}
		})
	})
	
	$(".getList").click(function(){
		var stime=$("input[name=stime]").val();
			etime=$("input[name=etime]").val();
			location.href="{:url('excel/getUserList')}"+"?stime="+stime+"&etime="+etime+"&type=1";
			/*type=$("select[name=type]").find("option:selected").val();
		if (type==1) {
			location.href="{:url('excel/getUserList')}"+"?stime="+stime+"&etime="+etime+"&type="+type;
		}else{
			layer.msg('只可下载培训机构数据');
		}*/
	})
</script>
</body>
</html>